﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class StorageDAL : PageDAL<StorageModel>
    {
        public StorageModel GetModelByID(string TableName, int id)
        {
            string sql = $"select * from  {TableName} where id='{id}'";
            DataTable dt = new DBHelper().GetDataTable(sql);
            StorageModel model = new StorageModel()
            {
                ID = int.Parse(dt.Rows[0]["id"].ToString()),
                Time = DateTime.Parse(dt.Rows[0]["Time"].ToString()),
                UserID = int.Parse(dt.Rows[0]["UserID"].ToString()),
                State = int.Parse(dt.Rows[0]["State"].ToString()),
            };
            return model;
        }
        public bool Sh(int a, int pid)
        {
            string sql = $"update Storage set State={a} where id={pid}";
            return new DBHelper().Zsg(sql);
        }
    }
}
